<!doctype html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../assert_selection.js"></script>
<script>
const isMac = navigator.platform.indexOf('Mac') === 0;
const kBehaviors = window.internals ? ['mac', 'win'] : isMac ? ['mac'] : ['win'];
for (const behavior of kBehaviors) {
  if (window.internals) {
    internals.settings.setEditingBehavior(behavior);
    internals.settings.setSelectTrailingWhitespaceEnabled(behavior !== 'mac');
  }

selection_test(
  '<div contenteditable dir="ltr">|they said "\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  selection => selection.modify('extend', 'right', 'word'),
  behavior === 'mac'
      ? '<div contenteditable dir="ltr">^they| said "\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>'
      : '<div contenteditable dir="ltr">^they |said "\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  `${behavior} 18-0 ltr right word`);

selection_test(
  '<div contenteditable dir="ltr">t|hey said "\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  selection => selection.modify('extend', 'right', 'word'),
  behavior === 'mac'
      ? '<div contenteditable dir="ltr">t^hey| said "\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>'
      : '<div contenteditable dir="ltr">t^hey |said "\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  `${behavior} 18-1 ltr right word`);

selection_test(
  '<div contenteditable dir="ltr">th|ey said "\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  selection => selection.modify('extend', 'right', 'word'),
  behavior === 'mac'
      ? '<div contenteditable dir="ltr">th^ey| said "\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>'
      : '<div contenteditable dir="ltr">th^ey |said "\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  `${behavior} 18-2 ltr right word`);

selection_test(
  '<div contenteditable dir="ltr">the|y said "\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  selection => selection.modify('extend', 'right', 'word'),
  behavior === 'mac'
      ? '<div contenteditable dir="ltr">the^y| said "\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>'
      : '<div contenteditable dir="ltr">the^y |said "\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  `${behavior} 18-3 ltr right word`);

selection_test(
  '<div contenteditable dir="ltr">they| said "\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  selection => selection.modify('extend', 'right', 'word'),
  behavior === 'mac'
      ? '<div contenteditable dir="ltr">they^ said| "\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>'
      : '<div contenteditable dir="ltr">they^ |said "\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  `${behavior} 18-4 ltr right word`);

selection_test(
  '<div contenteditable dir="ltr">they |said "\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  selection => selection.modify('extend', 'right', 'word'),
  behavior === 'mac'
      ? '<div contenteditable dir="ltr">they ^said| "\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>'
      : '<div contenteditable dir="ltr">they ^said |"\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  `${behavior} 18-5 ltr right word`);

selection_test(
  '<div contenteditable dir="ltr">they s|aid "\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  selection => selection.modify('extend', 'right', 'word'),
  behavior === 'mac'
      ? '<div contenteditable dir="ltr">they s^aid| "\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>'
      : '<div contenteditable dir="ltr">they s^aid |"\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  `${behavior} 18-6 ltr right word`);

selection_test(
  '<div contenteditable dir="ltr">they sa|id "\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  selection => selection.modify('extend', 'right', 'word'),
  behavior === 'mac'
      ? '<div contenteditable dir="ltr">they sa^id| "\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>'
      : '<div contenteditable dir="ltr">they sa^id |"\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  `${behavior} 18-7 ltr right word`);

selection_test(
  '<div contenteditable dir="ltr">they sai|d "\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  selection => selection.modify('extend', 'right', 'word'),
  behavior === 'mac'
      ? '<div contenteditable dir="ltr">they sai^d| "\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>'
      : '<div contenteditable dir="ltr">they sai^d |"\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  `${behavior} 18-8 ltr right word`);

selection_test(
  '<div contenteditable dir="ltr">they said| "\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  selection => selection.modify('extend', 'right', 'word'),
  behavior === 'mac'
      ? '<div contenteditable dir="ltr">they said^ "\u202Bcar| \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>'
      : '<div contenteditable dir="ltr">they said^ "\u202Bcar |\u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  `${behavior} 18-9 ltr right word`);

selection_test(
  '<div contenteditable dir="ltr">they said |"\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  selection => selection.modify('extend', 'right', 'word'),
  behavior === 'mac'
      ? '<div contenteditable dir="ltr">they said ^"\u202Bcar| \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>'
      : '<div contenteditable dir="ltr">they said ^"\u202Bcar |\u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  `${behavior} 18-10 ltr right word`);

selection_test(
  '<div contenteditable dir="ltr">they said "|\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  selection => selection.modify('extend', 'right', 'word'),
  behavior === 'mac'
      ? '<div contenteditable dir="ltr">they said "^\u202Bcar| \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>'
      : '<div contenteditable dir="ltr">they said "^\u202Bcar |\u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  `${behavior} 18-11 ltr right word`);

selection_test(
  '<div contenteditable dir="ltr">they said "\u202B|car \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  selection => selection.modify('extend', 'right', 'word'),
  behavior === 'mac'
      ? '<div contenteditable dir="ltr">they said "\u202B^car| \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>'
      : '<div contenteditable dir="ltr">they said "\u202B^car |\u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  `${behavior} 18-12 ltr right word`);

selection_test(
  '<div contenteditable dir="ltr">they said "\u202Bc|ar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  selection => selection.modify('extend', 'right', 'word'),
  behavior === 'mac'
      ? '<div contenteditable dir="ltr">they said "\u202Bc^ar| \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>'
      : '<div contenteditable dir="ltr">they said "\u202Bc^ar |\u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  `${behavior} 18-13 ltr right word`);

selection_test(
  '<div contenteditable dir="ltr">they said "\u202Bca|r \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  selection => selection.modify('extend', 'right', 'word'),
  behavior === 'mac'
      ? '<div contenteditable dir="ltr">they said "\u202Bca^r| \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>'
      : '<div contenteditable dir="ltr">they said "\u202Bca^r |\u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  `${behavior} 18-14 ltr right word`);

selection_test(
  '<div contenteditable dir="ltr">they said "\u202Bcar| \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  selection => selection.modify('extend', 'right', 'word'),
  behavior === 'mac'
      ? '<div contenteditable dir="ltr">they said "\u202Bcar^ \u05D3\u05D4\u05D5| \u05D0\u05D1\u05D2\u202C."</div>'
      : '<div contenteditable dir="ltr">they said "\u202Bcar^ |\u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  `${behavior} 18-15 ltr right word`);

selection_test(
  '<div contenteditable dir="ltr">they said "\u202Bcar |\u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  selection => selection.modify('extend', 'right', 'word'),
  behavior === 'mac'
      ? '<div contenteditable dir="ltr">they said "\u202Bcar ^\u05D3\u05D4\u05D5| \u05D0\u05D1\u05D2\u202C."</div>'
      : '<div contenteditable dir="ltr">they said "\u202Bcar ^\u05D3\u05D4\u05D5 |\u05D0\u05D1\u05D2\u202C."</div>',
  `${behavior} 18-16 ltr right word`);

selection_test(
  '<div contenteditable dir="ltr">they said "\u202Bcar \u05D3|\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  selection => selection.modify('extend', 'right', 'word'),
  behavior === 'mac'
      ? '<div contenteditable dir="ltr">they said "\u202Bcar \u05D3^\u05D4\u05D5| \u05D0\u05D1\u05D2\u202C."</div>'
      : '<div contenteditable dir="ltr">they said "\u202Bcar \u05D3^\u05D4\u05D5 |\u05D0\u05D1\u05D2\u202C."</div>',
  `${behavior} 18-17 ltr right word`);

selection_test(
  '<div contenteditable dir="ltr">they said "\u202Bcar \u05D3\u05D4|\u05D5 \u05D0\u05D1\u05D2\u202C."</div>',
  selection => selection.modify('extend', 'right', 'word'),
  behavior === 'mac'
      ? '<div contenteditable dir="ltr">they said "\u202Bcar \u05D3\u05D4^\u05D5| \u05D0\u05D1\u05D2\u202C."</div>'
      : '<div contenteditable dir="ltr">they said "\u202Bcar \u05D3\u05D4^\u05D5 |\u05D0\u05D1\u05D2\u202C."</div>',
  `${behavior} 18-18 ltr right word`);

selection_test(
  '<div contenteditable dir="ltr">they said "\u202Bcar \u05D3\u05D4\u05D5| \u05D0\u05D1\u05D2\u202C."</div>',
  selection => selection.modify('extend', 'right', 'word'),
  behavior === 'mac'
      ? '<div contenteditable dir="ltr">they said "\u202Bcar \u05D3\u05D4\u05D5^ \u05D0\u05D1\u05D2\u202C."|</div>'
      : '<div contenteditable dir="ltr">they said "\u202Bcar \u05D3\u05D4\u05D5^ |\u05D0\u05D1\u05D2\u202C."</div>',
  `${behavior} 18-19 ltr right word`);

selection_test(
  '<div contenteditable dir="ltr">they said "\u202Bcar \u05D3\u05D4\u05D5 |\u05D0\u05D1\u05D2\u202C."</div>',
  selection => selection.modify('extend', 'right', 'word'),
  '<div contenteditable dir="ltr">they said "\u202Bcar \u05D3\u05D4\u05D5 ^\u05D0\u05D1\u05D2\u202C."|</div>',
  `${behavior} 18-20 ltr right word`);

selection_test(
  '<div contenteditable dir="ltr">they said "\u202Bcar \u05D3\u05D4\u05D5 \u05D0|\u05D1\u05D2\u202C."</div>',
  selection => selection.modify('extend', 'right', 'word'),
  '<div contenteditable dir="ltr">they said "\u202Bcar \u05D3\u05D4\u05D5 \u05D0^\u05D1\u05D2\u202C."|</div>',
  `${behavior} 18-21 ltr right word`);

selection_test(
  '<div contenteditable dir="ltr">they said "\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1|\u05D2\u202C."</div>',
  selection => selection.modify('extend', 'right', 'word'),
  '<div contenteditable dir="ltr">they said "\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1^\u05D2\u202C."|</div>',
  `${behavior} 18-22 ltr right word`);

selection_test(
  '<div contenteditable dir="ltr">they said "\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2|\u202C."</div>',
  selection => selection.modify('extend', 'right', 'word'),
  '<div contenteditable dir="ltr">they said "\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2^\u202C."|</div>',
  `${behavior} 18-23 ltr right word`);

selection_test(
  '<div contenteditable dir="ltr">they said "\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C|."</div>',
  selection => selection.modify('extend', 'right', 'word'),
  '<div contenteditable dir="ltr">they said "\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C^."|</div>',
  `${behavior} 18-24 ltr right word`);

selection_test(
  '<div contenteditable dir="ltr">they said "\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C.|"</div>',
  selection => selection.modify('extend', 'right', 'word'),
  '<div contenteditable dir="ltr">they said "\u202Bcar \u05D3\u05D4\u05D5 \u05D0\u05D1\u05D2\u202C.^"|</div>',
  `${behavior} 18-25 ltr right word`);
}
</script>
